﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.SqlClient;

namespace RecipeBuildUnits
{
    public partial class frmrp1 : Form
    {
        public frmrp1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           // this.classTableAdapter.Fill(this..Class);
            SqlConnection conn = Utils.getConnection();
            SqlCommand cmd = new SqlCommand("SELECT * FROM Ingridient", conn);
            conn.Open();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet1 ds = new DataSet1();
            da.Fill(ds, "Ingridient");
            CrystalReport1 ingList = new CrystalReport1();
            ingList.SetDataSource(ds);
            crystalReportViewer1.ReportSource = ingList;
            conn.Close();
        }

       private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
       {
           // SqlConnection conn = Utils.getConnection();
          //SqlCommand cmd = new SqlCommand("SELECT * FROM Ingridient WHERE IngID="+comboBox1.SelectedValue.ToString(), conn);
            
         //  conn.Open();
          //  SqlDataAdapter da = new SqlDataAdapter(cmd);
          //  DataSet1 ds = new DataSet1();
          //  da.Fill(ds, "Ingridient");
          //  CrystalReport1 ingList = new CrystalReport1();
          //  ingList.SetDataSource(ds);
          //  crystalReportViewer1.ReportSource = ingList;
         // crystalReportViewer1.RefreshReport();
           // conn.Close();
       }

        private void frmrp1_Load(object sender, EventArgs e)
        {
            SqlConnection conn = Utils.getConnection();
            DataTable dt;
            if (conn != null)
            {
                dt = Utils.getDataTable(conn, "IngType");
                comboBox1.DataSource = dt;
                comboBox1.DisplayMember = dt.Columns[1].ToString();
                comboBox1.ValueMember = dt.Columns[0].ToString();
                MessageBox.Show(comboBox1.SelectedValue.ToString());
            }
            conn.Close();
        }
    }
}
